#include <iostream>
using namespace std;

template<class T,int capacity = 10>
class Stack{
public:
Stack()
:_data(new T[capacity])
,_top(-1)
    {
        cout << "Stack()"<<endl;
    }
~Stack(){
    cout <<"~Stack()"<<endl;
    if(_data){
        delete [] _data;
        _data = nullptr;
    }
}
bool empty()const{
    return _top == -1;
}
bool full()const{
    return _top == capacity -1;
}
void push(const T & value){
    _data[++_top] = value;
}
void pop(){
    --_top;
}
T top(){
    return _data[_top];
}

private:
T * _data;
int _top;
};
void test(){
  Stack<int ,20>stal;
  stal.push(1);
  stal.push(2);
  stal.push(3);
  for(int i=0 ; i < 3;i++){
      cout<<stal.top()<<endl;
      stal.pop();
  }
  Stack<double>sta2;
  Stack<string>sta3;
  sta3.push("hello");
  sta3.push("c++");
  sta3.push("world");
  for(size_t i =0;i<3;i++){
      cout<<sta3.top()<<endl;
      sta3.pop();
  }

}
int main()
{
    test();
    return 0;
}

